#include<bits/stdc++.h>
using namespace std;
const long long maxn=100005;
long long T;
long long n,m,L,V;
long long d[maxn],v[maxn],a[maxn];
long long p[maxn];
long long as1,as2;
pair<long long,long long>nne[maxn];long long topn;
long long find(long long x){
    for(long long i=1;i<=m;i++){
        if(p[i]>=x)return i;
    }
    return -1;
}
long long findl(long long x){
    for(long long i=m;i>0;i--){
        if(p[i]<=x)return i;
    }
    return -1;
}
bool cmp(pair<long long,long long>a,pair<long long,long long>b){
    return a.second<b.second;
}
long long TASK1,TASK2;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&T);
    while(T--){
        as1=0;as2=0;TASK1=1;TASK2=1;
        topn=0;
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        for(long long i=1;i<=n;i++){
            scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);if(a[i]!=0)TASK1=0;if(a[i]<=0)TASK2=0;
        }
        for(long long i=1;i<=m;i++){
            scanf("%lld",&p[i]);
        }
        if(TASK1==1){for(long long i=1;i<=n;i++)if(v[i]>V)if(d[i]<p[m])as2=1,as1++;printf("%lld %lld\n",as1,m-as2);}
        else if(TASK2==1){for(long long i=1;i<=n;i++)if(d[i]<p[m])if((v[i]*v[i]+2*(p[m]-d[i])*a[i])>V*V)as2=1,as1++;printf("%lld %lld\n",as1,m-as2);}
        else{
            long long bl0=0,list_0=-1,list_1=-1;
            for(long long i=1;i<=n;i++)
                if(a[i]==0){if(v[i]>V)if(d[i]<p[m])as1++,bl0=1,list_0=max(list_0,d[i]);}
                else if(a[i]>0){if(p[m]>d[i])if((v[i]*v[i]+2*(p[m]-d[i])*a[i])>V*V)as1++,list_1=max(list_1,findl(ceil((V+v[i])*(V-v[i])*2.000000/a[i])));}
                else{
                    if(p[m]>d[i])
                        if(v[i]*v[i]+2*a[i]*(p[find(d[i])]-d[i])>V*V){
                            nne[++topn].first=d[i];
                            nne[topn].second=ceil((V+v[i])*(V-v[i])/2.000000/a[i]+d[i]);
                            as1++;
                        }
                }
            sort(nne+1,nne+topn+1,cmp);
            long long last=0;
            for(long long i=1;i<=topn;i++){
                if(nne[i].first<=p[last])continue;
                as2++;
                while(p[last]<nne[i].second&&last<=m)last++;last--;
            }
            if(max(list_1,list_0)>p[last])as2++;
            printf("%lld %lld\n",as1,m-as2);
        }
    }
}